package com.atguigu.search.thread;

import java.util.concurrent.Executors;
import java.util.concurrent.ScheduledExecutorService;
import java.util.concurrent.TimeUnit;

/**
 * Created by 13 on 2017/5/5.
 */
public class ScheduledExecutorServiceDemo {
  public static void main(String args[]) {
    ScheduledExecutorService scheduledExecutorService = Executors.newScheduledThreadPool(10);

    scheduledExecutorService.scheduleAtFixedRate(new Runnable() {
      @Override
      public void run() {
        try {
          Thread.sleep(1000);
          System.out.println(System.currentTimeMillis() / 1000);
        } catch (InterruptedException e) {
          e.printStackTrace();
        }
      }
    }, 0, 2, TimeUnit.SECONDS);
  }
}
